<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="renderer" content="webkit">
    <title>经销商统计分析</title>
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/sqBlue/css/all.css">
    <link rel="stylesheet" type="text/css" href="<%=path %>/resource/lib/ligerUI/skins/sqBlue/css/sq-sj.css">
    <jsp:include page="../../../import.jsp" flush="true"/>
    <style type="text/css">
        .l-text-wrapper{
            display: inline-block;
        }
        .l-form div.btnsBox{
            text-align: left;
        }
        .l-form div.btm{
            padding: 0;
        }
        .form_view{
            padding: 10px 0;
        }
    </style>
</head>

<body class="iframeBody">
<div class="Wrapper">
    <div class="index_content">
        <div class="passageway">
            <div class="form_view">
                <form id="searchBar">
                    <div class="fieldset1 clearFix">
                        <div class="btnsBox">
                            <span id="yBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('1')">昨天</span>
                            <span id="sBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('7')">近7天</span>
                            <span id="fBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('15')">近15天</span>
                            <span id="tBtn" class="sq-button sq-button-round" onclick="javaScript:getAppStatsDataInfo('30')">近30天</span>
                        </div>
                        <div class="sqPanel_body">
                            <div class="fieldBox">
                                <div class="label">自定义时间设置</div>
                                <div class="field">
                                    <input name="dateMin" id="dateMin" type="text" class="ui-datepicker" value="" >
                                    -
                                    <input name="dateMax" id="dateMax" type="text" class="ui-datepicker" value="">
                                </div>
                            </div>
                            <div class="fieldBox">
                                <div class="label">经销商名称</div>
                                <div class="field">
                                    <input name="splNm" id="splNm" type="text"/>
                                </div>
                            </div>
                            <div class="fieldBox">
                                <div class="field">
                                    <input name="splId" id="splId" type="hidden" />
                                </div>
                            </div>
                        </div>

                        <div class="btnsBox btm">
                            <span id="searchBtn" class="sq-button sq-button-round">查询</span>
<!--                             <span id="detailBtn" class="sq-button sq-button-round">导出表格</span>
 -->                            <span id="clearBtn" class="sq-button sq-button-round">清空</span>
                        </div>
                    </div>
                </form>
            </div>
            <div class="passageway_title">经销商分析</div>
            <div class="second_level_t">文章类</div>
            <div class="passageway_list">
                <dl>
                    <dt class="text_number" id="articleShareCount"></dt>
                    <dd>
                        <span class="list_title_text">文章分享次数</span>
                    </dd>
                </dl>
                <dl>
                    <dt class="text_number" id="articleBrowseCount" ></dt>
                    <dd>
                        <span class="list_title_text">文章浏览量</span>
                    </dd>
                </dl>
                <dl>
                    <dt class="text_number" id="articleConsultCount"></dt>
                    <dd>
                        <span class="list_title_text">电话拨号量</span>
                    </dd>
                </dl>
            </div>
            <div class="second_level_t">店铺类</div>
            <div class="passageway_list">
                <dl>
                    <dt class="text_number" id="storeShareCount"></dt>
                    <dd>
                        <span class="list_title_text">文章分享次数</span>
                    </dd>
                </dl>
                <dl>
                    <dt class="text_number" id="storeBrowseCount"></dt>
                    <dd>
                        <span class="list_title_text">文章浏览量</span>
                    </dd>
                </dl>
                <dl>
                    <dt class="text_number" id="storeConsultCount"></dt>
                    <dd>
                        <span class="list_title_text">电话拨号量</span>
                    </dd>
                </dl>
            </div>
        </div>
    </div>
</div>

<script src="<%=path %>/resource/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
<script src="<%=path %>/resource/lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="<%=path %>/resource/lib/sq.all.js" type="text/javascript"></script>

<script type="text/javascript">
    var form=null,formData=null, data=null,dayRegionNum=null;
    $(function () {
        form = $("#searchBar").ligerForm();
        formData = form.getData();
        $.ajax({
            type: 'post',
            dataType:'json',
            url: '<%=path%>/mongo/storeStats/getStoreStatsDataInfo.do',
            async:false,
            data:formData,
            beforeSend:function(){
                wait_dialog=$.ligerDialog.SQalert({content: '正在查询...',SQ_type: "waitting"});
            },
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    //window.open(msg.data);
                    console.log("data>>"+JSON.stringify(msg.data));
                    data = msg.data ;;
                    $("#articleBrowseCount").html(data.articleBrowseCount);
                    $("#articleShareCount").html(data.articleShareCount);
                    $("#articleConsultCount").html(data.articleConsultCount);
                    $("#storeBrowseCount").html(data.storeBrowseCount);
                    $("#storeShareCount").html(data.storeShareCount);
                    $("#storeConsultCount").html(data.storeConsultCount);
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
        /* 清空 */
        $("#clearBtn").click(function (event) {
            $('#splId').val('');
            $('#splNm').val('');
            clearLigerForm("searchBar");
            dayRegionNum = null;
        });

        /* 查询 */
        $("#searchBtn").click(function (event) {
            form = liger.get("searchBar");
            var formData = form.getData();
            formData['splId'] = $('#splId').val();
           /*  if(dayRegionNum){
                formData['dayRegion'] = dayRegionNum ;
            } */
            console.log(JSON.stringify(formData));
            $.ajax({
                type: 'post',
                dataType:'json',
                url: '<%=path%>/mongo/storeStats/getStoreStatsDataInfo.do',
                async:false,
                data:formData,
                beforeSend:function(){
                    wait_dialog=$.ligerDialog.SQalert({content: '正在查询...',SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        //window.open(msg.data);
                        console.log("data>>"+JSON.stringify(msg.data));
                        data = msg.data ;
                        $("#articleBrowseCount").html(data.articleBrowseCount);
                        $("#articleShareCount").html(data.articleShareCount);
                        $("#articleConsultCount").html(data.articleConsultCount);
                        $("#storeBrowseCount").html(data.storeBrowseCount);
                        $("#storeShareCount").html(data.storeShareCount);
                        $("#storeConsultCount").html(data.storeConsultCount);
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        //导出
        $("#detailBtn").click(function (event) {
            var form = liger.get("searchBar");
            var data = form.getData();
            data['splId'] = $('#splId').val();
            if(dayRegionNum){
                data['dayRegion'] = dayRegionNum ;
            }
            var wait_dialog;
            $.ajax({
                type: 'post',
                dataType:'json',
                url: '<%=path%>/mongo/storeStats/exportStoreStatsDataList.do',
                data:data,
                beforeSend:function(){
                    wait_dialog=$.ligerDialog.SQalert({content: '导出数据中...',SQ_type: "waitting"});
                },
                success:function(msg){
                    wait_dialog.close();
                    if(msg.success == 1){
                        //window.open(msg.data);
                        console.log(msg.data);
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                    }else{
                        $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                    }
                }
            });
        });

        $("#splNm").ligerComboBox({
            width: 200,
            slide: false,
            selectBoxWidth: 700,
            selectBoxHeight: 450,
            valueField: 'id',
            textField: 'splNm',
            condition: { fields: [{ name: 'splNm', label: '客户', width: 90, type: 'text' }] },
            grid: getGridOptions(true),
            // delayLoadGrid: false,
            /*condition:condition,*/
            conditionSearchClick: function (e)
            {
                //debugger
                if(e.rules[0] && e.rules[0].value){
                    e.grid.set('parms', {splNm: e.rules[0].value});
                }else{
                    e.grid.set('parms','');
                }
                e.grid.reload();

            },
            onSelected: function (splId)
            {
                console.log('选择的是' + splId);
                $('#splId').val(splId);
            }
        });
    });

    /**
     * 查询最近几天的统计情况
     * @param dayRegion
     * */
    function getAppStatsDataInfo(dayRegion){
        if(!dayRegion){
            $.ligerDialog.SQalert({content:"查询最近几天的数据参数不能为空！", SQ_type: "error"});
            return ;
        }
        dayRegionNum = dayRegion;
        form = liger.get("searchBar");
        var formData = form.getData();
        formData['dayRegion'] = dayRegion ;
        console.log(JSON.stringify(formData));
        $.ajax({
            type: 'post',
            dataType:'json',
            url: '<%=path%>/mongo/storeStats/getStoreStatsDataInfo.do',
            async:false,
            data:formData,
            beforeSend:function(){
                wait_dialog=$.ligerDialog.SQalert({content: '正在查询...',SQ_type: "waitting"});
            },
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    //window.open(msg.data);
                    console.log("data>>"+JSON.stringify(msg.data));
                    data = msg.data ;
                    $("#articleBrowseCount").html(data.articleBrowseCount);
                    $("#articleShareCount").html(data.articleShareCount);
                    $("#articleConsultCount").html(data.articleConsultCount);
                    $("#storeBrowseCount").html(data.storeBrowseCount);
                    $("#storeShareCount").html(data.storeShareCount);
                    $("#storeConsultCount").html(data.storeConsultCount);
                }else{
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                }
            }
        });
    }

    function getGridOptions(checkbox)
    {
        var options = {
            columns: [
                { display: '供应商ID', name: 'id', align: 'left', width: 120, minWidth: 60 },
                { display: '供应商名称', name: 'splNm', minWidth: 120, width: 100 },
                { display: '申请人', name: 'applyPerNm', minWidth: 50 , enabledSort:false},
                { display: '联系电话', name: 'applyTel', minWidth: 120 , enabledSort:false}
                /* { display: '联系名', name: 'ContactName', minWidth: 140, width: 100 },
                 { display: '电话', name: 'Phone', width: 100 },
                 { display: '城市', name: 'City', width: 100 },
                 { display: '国家', name: 'Country', width: 100 }*/
            ], switchPageSizeApplyComboBox: false,
            url : '<%=path%>/product/splInfo/initList.do',
            pageSize: 10,
            root:'rows',
            record:'total',
            width: '100%',
            height:'100%'
            //checkbox: checkbox
        };
        return options;
    }

    var condition = { fields: [{ name: 'splNm', label: '商家名称:',width:180,type:'text' }] };
</script>

</body>
</html>
